var default_content="";

$(document).ready(function(){
	checkURL();
	
	$('#menu li a').click(function (e){
		checkURL(this.hash);
	});
	
	$('footer a').click(function (e){
		checkURL(this.hash);
	});
	
	//filling in the default content
	default_content = $('#sechome').html();
		
	setInterval("checkURL()",200);	
});

var lasturl = "";

function checkURL(hash){
	if(!hash) hash = window.location.hash;
	
	if(hash != lasturl){
		lasturl = hash;
			
		// FIX - if we've used the history buttons to return to the homepage,
		// fill the pageContent with the default_content
		
		if(hash == ""){
			$("#content").html(default_content);
		}else{
			loadPage(hash);
		}//if
	}
}


function loadPage(url){
	url=url.replace('#','');
	switch(url){
		case "home": 
			$("#content").load("pages/home.php");
			break;
		case "redirect":
			$("#content").load("pages/redirect.php");
		default:
			$("#content").load("pages/home.php");
			break;
	}//switch
}//loadpage